﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Protegidos/Administracao/GENTE_Adm.master" AutoEventWireup="true" CodeFile="acCadSindicatos.aspx.cs" Inherits="Protegidos_Administracao_Cadastros_acCadSindicatos" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphSubConteudo" Runat="Server">

<telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
            
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="RadGrid2">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>            
            
<script type="text/javascript">
    //the following code use radconfirm to mimic the blocking of the execution thread.
    //The approach has the following limitations:
    //1. It works inly for elements that have *click* method, e.g. links and buttons
    //2. It cannot be used in if(!confirm) checks
    window.blockConfirm = function(text, mozEvent, oWidth, oHeight, callerObj, oTitle) {
        var ev = mozEvent ? mozEvent : window.event; //Moz support requires passing the event argument manually   
        //Cancel the event   
        ev.cancelBubble = true;
        ev.returnValue = false;
        if (ev.stopPropagation) ev.stopPropagation();
        if (ev.preventDefault) ev.preventDefault();

        //Determine who is the caller   
        var callerObj = ev.srcElement ? ev.srcElement : ev.target;

        //Call the original radconfirm and pass it all necessary parameters   
        if (callerObj) {
            //Show the confirm, then when it is closing, if returned value was true, automatically call the caller's click method again.   
            var callBackFn = function(arg) {
                if (arg) {
                    callerObj["onclick"] = "";
                    if (callerObj.click) callerObj.click(); //Works fine every time in IE, but does not work for links in Moz   
                    else if (callerObj.tagName == "A") //We assume it is a link button!   
                    {
                        try {
                            eval(callerObj.href)
                        }
                        catch (e) { }
                    }
                }
            }

            radconfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle);
        }
        return false;
    }  
            </script>

<table width="99%" align="center">
    <tr>
        <td>
              
            <div class="Titulo01">Dados Cadastrais</div>
            <div class="Titulo02">Cadastros / Gerais / Sindicatos</div>

        </td>    
    </tr>
    
    <tr>
        <td>
            
            <table width="99%" align="right">
                <tr>
                    <td>
                        
			            <telerik:RadTabStrip ID="RadTabStrip2" runat="server" Skin="Telerik" MultiPageID="RadMultiPage1" SelectedIndex="0">
                            <Tabs>
                                <telerik:RadTab Text="Dados Gerais" runat="server" Selected="True">
                                </telerik:RadTab>
                                <telerik:RadTab Text="Contatos" runat="server">
                                </telerik:RadTab>
                            </Tabs>
                        </telerik:RadTabStrip>
			            
			            <telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="0">
                            <telerik:RadPageView runat="server" ID="RadPageView1">
                            
                                <!-- INICIO - Dados Gerais -->
                                
                                <table width="100%" align="right">
                                    <tr>
                                        <td>
                                            <div class="subTitulo_pagina">Dados Principais</div>
                                            <div class="espaco"></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <table class="textoCZ_12">
                                            <asp:Panel ID="ContentPanel2" runat="server" DefaultButton="btnVerificar">
                                                <tr>
                                                    <td style="width: 150px">CNPJ:</td>
                                                    <td>
                                                        <asp:TextBox ID="txtCNPJ" runat="server"></asp:TextBox>&nbsp;&nbsp;
                                                        <ajax:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="txtCNPJ" Mask="99,999,999/9999-99" MaskType="None" MessageValidatorTip="true" OnFocusCssClass="MaskedEditFocus" OnInvalidCssClass="MaskedEditError" ClearMaskOnLostFocus = "false" />
                                                        <ajax:MaskedEditValidator ID="MaskedEditValidator1" runat="server"
                                                            ControlToValidate="txtCNPJ" 
                                                            ControlExtender="MaskedEditExtender1" 
                                                            Display="Dynamic" 
                                                            TooltipMessage="Ex: 00.000.000/0000-00 " 
                                                            IsValidEmpty="false" 
                                                            EmptyValueMessage="CNPJ obrigatório" 
                                                            InvalidValueMessage="CNPJ Inválido" />
                                                        <asp:RequiredFieldValidator runat="server" ID="NReq" ControlToValidate="txtCNPJ" InitialValue="__.___.___/____-__" Display="None" ErrorMessage="O CNPJ é obrigatório!" ValidationGroup="1" />
                                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" ValidationExpression="\d{2}.?\d{3}.?\d{3}/?\d{4}-?\d{2}"
                                                        runat="server" ControlToValidate="txtCNPJ" ErrorMessage=" * Requer CNPJ válido." ValidationGroup="1"></asp:RegularExpressionValidator>
                                                        
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 150px">&nbsp;</td>
                                                    <td>
                                                        <asp:Button ID="btnVerificar" runat="server" Text="Verificar" Width="90px" onclick="btnVerificar_Click"  ValidationGroup="1" />
                                                        <asp:Label ID="lblMsg" runat="server" Text="" CssClass="textoVR_11B"></asp:Label>
                                                    </td>
                                                </tr>
                                            </asp:Panel>
                                                <tr runat="server" id="trTipoOrgan" >
                                                    <td>Tipo Organização:</td>
                                                    <td>
                                                        <asp:CheckBox ID="cbPatrocidador" runat="server" Text="" Enabled="false" />Patrocinador&nbsp;&nbsp;
                                                        <asp:CheckBox ID="cbPrestador" runat="server" Text="" Enabled="false" />Prestador&nbsp;&nbsp;
                                                        <asp:CheckBox ID="cbSindicato" runat="server" Text="" Enabled="false" />Sindicato&nbsp;&nbsp;
                                                        <asp:CheckBox ID="cbFornecedor" runat="server" Text="" Enabled="false" />Fornecedor
                                                    </td>
                                                </tr>
                                                <tr runat="server" id="trRazaoSocial">
                                                    <td>Nome:</td>
                                                    <td>
                                                        <asp:TextBox ID="txtRazaoSocial" runat="server" Width="300px"></asp:TextBox>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="txtRazaoSocial"
                                                            InitialValue="" ErrorMessage="* obrigatório" ValidationGroup="2" />
                                                    
                                                    </td>
                                                </tr>
                                                <tr runat="server" id="trNomeFantasia">
                                                    <td>Sigla:</td>
                                                    <td>
                                                        <asp:TextBox ID="txtNomeFantasia" runat="server" Width="300px"></asp:TextBox>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="txtNomeFantasia"
                                                            InitialValue="" ErrorMessage="* obrigatório" ValidationGroup="2" />
                                                    </td>
                                                </tr>
                                                <tr runat="server" id="trStatus">
                                                    <td>Status:</td>
                                                    <td>
                                                        <telerik:RadComboBox ID="rcbStatus" runat="server" Skin="Telerik" Width="240px" EmptyMessage="Selecione" AllowCustomText="true">
                                                            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                                                        </telerik:RadComboBox>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator3" ControlToValidate="rcbStatus"
                                                            InitialValue="" ErrorMessage="* obrigatório" ValidationGroup="2" />
                                                    </td>
                                                </tr>
                                                <tr runat="server" id="trDataBase">
                                                    <td>Data Base:</td>
                                                    <td>
                                                        <telerik:RadComboBox ID="rcbDataBase" runat="server" Skin="Telerik" Width="240px" EmptyMessage="Selecione" AllowCustomText="true">
                                                            <CollapseAnimation Type="OutQuint" Duration="200" />
                                                            <Items>
                                                                <telerik:RadComboBoxItem Text="Janeiro" Value="1" />
                                                                <telerik:RadComboBoxItem Text="Fevereiro" Value="2" />
                                                                <telerik:RadComboBoxItem Text="Março" Value="3" />
                                                                <telerik:RadComboBoxItem Text="Abril" Value="4" />
                                                                <telerik:RadComboBoxItem Text="Maio" Value="5" />
                                                                <telerik:RadComboBoxItem Text="Junho" Value="6" />
                                                                <telerik:RadComboBoxItem Text="Julho" Value="7" />
                                                                <telerik:RadComboBoxItem Text="Agosto" Value="8" />
                                                                <telerik:RadComboBoxItem Text="Setembro" Value="9" />
                                                                <telerik:RadComboBoxItem Text="Outubro" Value="10" />
                                                                <telerik:RadComboBoxItem Text="Novembro" Value="11" />
                                                                <telerik:RadComboBoxItem Text="Dezembro" Value="12" />
                                                            </Items>
                                                        </telerik:RadComboBox>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequireFieldValidator4" ControlToValidate="rcbDataBase"
                                                            InitialValue="" ErrorMessage="* obrigatório" ValidationGroup="2"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                                
                                <!-- FIM - Dados Gerais -->
                            
                            </telerik:RadPageView>
                            
                            <telerik:RadPageView runat="server" ID="RadPageView2">
                            
                                <!-- INICIO - Contatos -->
                                
                                <table width="100%" align="right">
                                    <tr>
                                        <td>
                                            <div class="subTitulo_pagina">Telefones</div>
                                            <div class="espaco"></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                                                                       
                                            <telerik:RadGrid ID="RadGrid1" Width="100%" Skin="Telerik" 
                                                runat="server" AllowPaging="True" AllowSorting="True"
                                                GridLines="None" AutoGenerateColumns="false" PageSize="20" OnNeedDataSource="RadGrid1_NeedDataSource"
                                                ShowStatusBar="True" >
                                                <MasterTableView TableLayout="Fixed" GridLines="None" DataKeyNames="IdTelefoneOrganizacao" CommandItemDisplay="Top">
                                                    
                                                    <CommandItemSettings AddNewRecordText=" Adicionar novo telefone" RefreshText=" Atualizar" />
                                                    <Columns>
                                                    <telerik:GridTemplateColumn>
                                                    <ItemTemplate>
                                                        <span style="font-weight: bold;">DDD:</span><%# Eval("DddTelefone")%>
                                                        <br /><span style="font-weight: bold;">Telefone: </span><%# Eval("Telefone")%>
                                                        <br /><span style="font-weight: bold;">Ramal: </span><%# Eval("Ramal")%>
                                                        <br /><span style="font-weight: bold;">Recado: </span><%# Eval("RecadoNome")%>
                                                        <br /><span style="font-weight: bold;">Tipo: </span><%# Eval("TipoTelefone.Descricao")%>
                                                        <br /><span style="font-weight: bold;">Status: </span><%# Eval("StatusTelefone.Descricao")%>
                                                        <br /><br />


                                                    </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
<telerik:GridButtonColumn ItemStyle-VerticalAlign="NotSet" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"                                  ConfirmText="Delete medication from kit list?" />
                                                    </Columns>
                                                    <EditFormSettings UserControlName="_forms/wucTelefones.ascx" EditFormType="WebUserControl">
                                                        <EditColumn UniqueName="EditCommandColumn1">
                                                        </EditColumn>
                                                    </EditFormSettings>

                                                </MasterTableView>
                                                <StatusBarSettings LoadingText="Aguarde..." ReadyText="Pronto" />
                                            </telerik:RadGrid>
                                            
                                        </td>
                                    </tr>
                                    
                                    <tr>
                                        <td>
                                            <div class="subTitulo_pagina">Endereços</div>
                                            <div class="espaco"></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            
                                            <telerik:RadGrid ID="RadGrid2" Width="100%" Skin="Telerik" 
                                                runat="server" AllowPaging="True" AllowSorting="True"
                                                GridLines="None" AutoGenerateColumns="false" PageSize="20" OnNeedDataSource="RadGrid2_NeedDataSource"
                                                ShowStatusBar="True" >
                                                <MasterTableView TableLayout="Fixed" GridLines="None" DataKeyNames="IdOrganizacaoEndereco" CommandItemDisplay="Top">
                                                    <ItemTemplate>
                                                       
                                                        <span style="font-weight: bold;">TipoLogradouro: </span><%# Eval("TipoLogradouro.Descricao")%>
                                                        <br /><span style="font-weight: bold;">Endereco: </span><%# Eval("Endereco")%>
                                                        <br /><span style="font-weight: bold;">Numero: </span><%# Eval("Numero")%>
                                                        <br /><span style="font-weight: bold;">Complemento: </span><%# Eval("Complemento")%>
                                                        <br /><span style="font-weight: bold;">Bairro: </span><%# Eval("Bairro")%>
                                                        <br /><span style="font-weight: bold;">Cep: </span><%# Eval("Cep")%>
                                                        <br /><span style="font-weight: bold;">Estado: </span><%# Eval("Cidade.Uf.Sigla")%>
                                                        <br /><span style="font-weight: bold;">Cidade: </span><%# Eval("Cidade.NomeCidade")%>
                                                        <br /><span style="font-weight: bold;">TipoEndereco: </span><%# Eval("TipoEndereco.Descricao")%>
                                                        <br /><span style="font-weight: bold;">StatusEndereco: </span><%# Eval("StatusEndereco.Descricao")%>
                                                        <br /><br />
                                                        

                                                        <asp:Button ID="btnEdit" runat="server" CommandName="Edit" Text="Editar" />
                                                        <asp:Button ID="btnDelete" runat="server" Text="Delete" CommandName="Remover" /> 

                                                    </ItemTemplate>
                                                    <CommandItemSettings AddNewRecordText=" Adicionar novo telefone" RefreshText=" Atualizar" />
                                                    <Columns>
                                                        <telerik:GridBoundColumn UniqueName="TipoLogradouro.Descricao"  HeaderText="TipoLogradouro" DataField="DddTelefone" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="Endereco"                  HeaderText="Endereco"       DataField="Telefone" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="Numero"                    HeaderText="Numero"         DataField="Ramal" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="Complemento"               HeaderText="Complemento"    DataField="RecadoNome" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="Bairro"                    HeaderText="Bairro"         DataField="TipoTelefone.Descricao" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="Cep"                       HeaderText="Cep"            DataField="StatusTelefone.Descricao" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="Cidade.Uf.Sigla"           HeaderText="Estado"         DataField="Cidade.Uf.Sigla" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="Cidade.NomeCidade"         HeaderText="Cidade"         DataField="Cidade.NomeCidade" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="TipoEndereco.Descricao"    HeaderText="TipoEndereco"   DataField="TipoEndereco.Descricao" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="StatusEndereco.Descricao"  HeaderText="StatusEndereco" DataField="StatusEndereco.Descricao" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                                    </Columns>
                                                    <EditFormSettings UserControlName="_forms/wucEnderecos.ascx" EditFormType="WebUserControl">
                                                        <EditColumn UniqueName="EditCommandColumn1">
                                                        </EditColumn>
                                                    </EditFormSettings>

                                                </MasterTableView>
                                                <StatusBarSettings LoadingText="Aguarde..." ReadyText="Pronto" />
                                            </telerik:RadGrid>
                                            
                                        </td>
                                    </tr>
                                </table>
                                
                                <!-- FIM - Contatos -->
                            
                            </telerik:RadPageView>
                        </telerik:RadMultiPage>
                        
                    </td>
                </tr>
                
                <tr>
                    <td align="right">
                    <br /><br />
                        <asp:Label ID="lblResultado" runat="server" Text=""></asp:Label>&nbsp;&nbsp;
                        <asp:Button ID="btnSalvar" runat="server" Text="Salvar" Width="110px" onclick="btnSalvar_Click" 
                             ValidationGroup="2" CausesValidation="true"/>&nbsp;&nbsp;<!-- OnClientClick="if (!blockConfirm('Confirma?', event, 330, 100,'','Confirmação')) return false;" -->
                        <asp:Button ID="btnLimpar" runat="server" Text="Limpar" Width="110px" 
                            onclick="btnLimpar_Click" />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                    <br />
                        <a href="acSindicatos.aspx">Voltar</a>
                    </td>
                </tr>
                
            </table>
            
        </td>    
    </tr>
    
</table>

</asp:Content>

